<?php $this->load->view('partials/notices'); ?>
<div id="page-heading">
		<h1><?php echo lang('user_list_title'); ?></h1>
	</div>
<form method="post" action="<?php echo site_url('admin/users/search');?>">	
<table cellspacing="0" cellpadding="0" border="0" id="id-form">
		<tbody><tr>
			<td><?php echo form_input('keyword', $keyword, 'class="inp-form" name="keyword" id="keyword"'); ?></td>
			<td><?php echo lang('user_active', 'active'); ?>:</td>
			<td><?php echo form_dropdown('active', array(0 => lang('global:select-all'), 1 => lang('global:yes'), 2 => lang('global:no') ), array($active), 'class="select_box" style="width:150px;"'); ?></td>
			<td><?php echo lang('user_group_label', 'group'); ?>:</td>
			<td><?php echo form_dropdown('group', array(0 => lang('global:select-all')) + $groups_select, array($group) , 'class="select_box" style="width:150px;"'); ?></td>
			<td valign="top">
			<input type="submit" class="form-submit" value="">
		</td>
		</tr>
	</tbody></table>
	</form>
<form id="mainform" method="post" action="<?php echo site_url('admin/users/action');?>">		
<table cellspacing="0" cellpadding="0" border="0" width="100%" id="product-table">
				<tbody><tr>
					<th class="table-header-check"><a id="toggle-all" ></a> </th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_name_label');?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_email_label');?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_group_label');?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_active'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_joined_label');?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('user_last_visit_label');?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('global:actions')?></a></th>
				</tr>
				<?php if (empty($users)):?>
				<tr>
					<td colspan="8"><?php echo lang('global:empty')?></td>
				</tr>
				<?php else:?>
				<?php foreach ($users as $key => $member): ?>
				<tr <?php if($key%2 == 0):?>class="alternate-row"<?php endif;?>>
					<td><input type="checkbox" name="action_to[]" value="<?php echo $member->id?>"/></td>
					<td><a target="_blank" href="<?php echo site_url('admin/profile/'. $member->id)?>"><?php echo $member->username?></a></td>
					<td><?php echo $member->email;?></td>
					<td><?php echo $member->group_name; ?></td>
					<td><?php echo $member->active ? lang('global:yes') : lang('global:no') ; ?></td>
					<td><?php echo format_date($member->created_on); ?></td>
					<td><?php echo ($member->last_login > 0 ? format_date($member->last_login) : lang('user_never_label')); ?></td>
					<td class="options-width">
					<a class="icon-1 info-tooltip" href="<?php echo site_url('admin/users/edit/' . $member->id);?>" title="<?php echo lang('buttons.edit');?>"></a>
					<a class="icon-2 info-tooltip" href="javascript:void(0);" onclick="if(confirm('<?php echo lang('global:delete')?>')){window.location.href='<?php echo site_url('admin/users/delete/' . $member->id);?>'}" title="<?php echo lang('buttons.delete');?>"></a>
					</td>
				</tr>
				<?php endforeach;?>
				<?php endif;?>
				</tbody>
</table>
<input type="hidden" name="btnAction"  id="btnAction" value=""/>
</form>
<script type="text/javascript">
	function submit_form(type)
	{
		if('activate' == type){
			$('#btnAction').val('activate');
		}else if('deactivate' == type){
			$('#btnAction').val('deactivate');
		}else if('delete' == type){
			if(confirm('<?php echo lang("global:delete_confirm")?>')){
				$('#btnAction').val('delete');
			}else{
				return;
			}
		}
		$('#mainform').submit();
	}
</script>
<div id="actions-box">
	<a href="" class="action-slider"></a>
	<div id="actions-box-slider">
		<a href="javascript:void(0);" onclick="submit_form('activate');" class="action-edit"><?php echo lang('user_activate_label');?></a>
		<a href="javascript:void(0);" onclick="submit_form('deactivate');" class="action-edit"><?php echo lang('deactivate_label');?></a>
		<a href="javascript:void(0);" onclick="submit_form('delete');" class="action-delete">Delete</a>
	</div>
	<div class="clear"></div>
</div>
<div align=center><div class="inner"><?php $this->load->view('partials/pagination'); ?></div></div>
